home *** CD-ROM | disk | FTP | other *** search
Text File | 1989-08-22 | 2.1 KB | 50 lines | [TEXT/GEOL] |
- Item 4260915 11-Aug-89 23:29
-
- From: ROSENSTEIN1 Rosenstein, Larry,APL
-
- To: D1220 Vari-Lite, Andy Meldrum,PRT
-
- cc: MACAPP.TECH$ MACAPP Tech
-
- Sub: re RespondsTo:
-
- Andy,
-
- I don't think it is technically possible to implement RespondsTo: in Object
- Pascal. Each method that is defined has a unique ID, so if two totally
- unrelated classes define the Foo method those methods are different.
-
- You mention that using Member is something that you are not supposed to do. I
- think using RespondsTo: is equally unclean. So if you feel that you need
- RespondsTo: then I would use Member instead. (The reasons for avoiding Member
- is that it is too procedural and not very object-oriented. Also, if you add
- new kinds of object later, you may need to modify the Member tests.)
-
- As you said the simplest solution is to define every possible method in the
- common ancestor class and implement those methods in the appropriate classes.
-
- You also mention a little about the user interface. I think that you should
- disable commands that don't make sense given the current selection. For
- example, the Set Intensity command should be disabled if none of the selected
- objects have an intensity.
-
- Doing this requires a way to test the attributes that an object has. You might
- do this using several methods that return a Boolean. These can default to
- returning FALSE in the common class, but can be overridden in subclasses. Or
- you could have a series of Boolean fields that you can test.
-
- If you have these fields, then you can test them to decide whether a given
- object has an intensity, for example. This is better than using Member since
- you won't be assuming that a particular class has a particular attribute.
-
- Larry Rosenstein
-
-
- P.S. It may be possible to come up with a better approach by thinking about the
- problem in a different way. Without knowing more it is hard to offer advice,
- but an example would be to think about making attributes classes. Perhaps an
- object in your program can have a list of attribute objects.
-
-
-
-